<!DOCTYPE html>
<html lang="ch">

<head>
    <title>AI</title>

    <!-- Meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">

    <link rel="stylesheet" href="../css/bootstrap.css">
    <link rel="stylesheet" href="../css/font-awesome.css">
    <link rel="stylesheet" href="../css/demo.css">
    <link rel="stylesheet" href="../css/test.css">
</head>

<body>
    <!-- header -->
    <header class="header fixed-top">
        <div class="branding">
            <div class="container-fluid position-relative pt-2">
                <div class="logo-wrapper">
                    <div class="site-logo">
                        <a class="navbar-brand" href="index.html">
                            <img class="logo-icon mr-2" src="../img/logo.svg" alt="logo">
                            <span class="logo-text">老师说得队  <span class="text-alt">聊天机器人</span></span>
                        </a>
                    </div>
                </div>
                <div class="d-flex justify-content-end align-items-center pt-2">
                    <form class="search-form" id="search-form" action="changeName()">
                        <input type="text" placeholder="为聊天机器人命名" name="check" class="form-control search-input" id="txt-chg">
                        <button class="btn search-btn" id="btn_chg"><i class="fa fa-check"></i></button>
                    </form>
                </div>
            </div>
        </div>
    </header>
    <!-- class detail -->
    <div class="class-detail">
        <div class="container">
            <h3 id="course-name"></h3>
            <div class="row">
                <div class="col-md-6">
                    <div class="card text-white">
                        <div class="card-header">聊天内容</div>
                        <div class="card-body">
                            <textarea class="form-control" style="width:100%;height: 100%;resize: none;overflow-x: none;overflow-y: scroll;" readonly="true" id="txt_view"></textarea>
                        </div>
                    </div>
                </div>
                <div class="col-md-6"></div>
            </div>
        </div>
    </div>

    <!-- class comment -->
    <div class="class-comment">
        <div class="container">
            <div class="class-comment-title"></div>
            <div class="class-comment-title"></div>
            <div class="class-comment-title"></div>
            <div class="row">
                <div class="col-md-6"></div>
                <div class="col-md-2 d-flex justify-content-end align-items-center pt-2">
                    <a class="btn btn-primary d-none d-lg-flex mb-5" id="btn_sub">发送</a>
                </div>
                <div class="col-md-4 comment-input">
                    <div class="comment-item">
                        <div class="comment-item-inner">
                            <div class="comment-info">
                                <div class="comment-description pb-0">
                                    <div class="input-group">
                                        <label id="comment-username">用户输入</label>
                                        <form action="">
                                            <div class="input-group form-group">
                                                <input type="text" id="txt_sub" class="form-control" placeholder="" aria-label="Example text with button addon" aria-describedby="button-addon1">
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                            <img src="../img/person-1.jpg" alt="Image" class="rounded-circle comment-img">
                        </div>
                    </div>
                </div>
            </div>


        </div>
    </div>



    <!-- footer -->
    <!-- <footer class="footer">
        <div class="footer-bottom text-center py-5">
            <ul class="social-list list-unstyled pb-4 mb-0">
                <li class="list-inline-item"><a href="#"><i class="fa fa-github"></i></a></li>
                <li class="list-inline-item"><a href="#"><i class="fa fa-twitter"></i></a></li>
                <li class="list-inline-item"><a href="#"><i class="fa fa-slack"></i></a></li>
                <li class="list-inline-item"><a href="#"><i class="fa fa-product-hunt"></i></a></li>
                <li class="list-inline-item"><a href="#"><i class="fa fa-facebook-f"></i></a></li>
                <li class="list-inline-item"><a href="#"><i class="fa fa-instagram"></i></a></li>
            </ul>
            <small class="copyright">Copyright &copy; 2019.All rights reserved.<a target=""></a></small>
        </div>
    </footer> -->

    <!-- Javascript -->
    <script src="../js/jquery-3.4.1.js"></script>
    <script src="../js/bootstrap.js"></script>
    <script src="../js/class_info.js"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
    <script type="text/javascript">
        var AppDomain = 'http://www.tuling123.com/openapi/api?key=a69e9d36f0724119b4eaeeb3520da5f7&info=';
        $(document).ready(function() {


            $("#btn_sub").click(function() {
                var user = '用户';

                var request_txt = $("#txt_sub").val();

                setView(user, request_txt);

                $.ajax({
                    type: 'post',
                    url: AppDomain + request_txt,
                    async: true, //异步
                    dataType: 'json',
                    success: function(data) {
                        console.log(JSON.stringify(data));

                        setView(resUser, data.text);

                    },
                    error: function(data) {
                        console.log(JSON.stringify(data));
                    }
                }); //end Ajax


            });

        });

        function setView(user, text) {
            var subTxt = user + " " + new Date().toLocaleTimeString() + '\n·' + text;
            $("#txt_view").val($("#txt_view").val() + '\n\n' + subTxt);

            var scrollTop = $("#txt_view")[0].scrollHeight;
            $("#txt_view").scrollTop(scrollTop);
        }
    </script>
</body>

</html>